package com.ruoyi.web.controller.data;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.student.domain.SchoolDegreeInfo;
import com.ruoyi.student.service.ISchoolDegreeInfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 此控制器归属数据中台
 */
@RestController("SchoolDegreeController")
@RequestMapping("/data/school/degree")
public class SchoolDegreeController extends BaseController {

    @Resource
    private ISchoolDegreeInfoService schoolGradeInfoService;


    /**
     * 查询学籍信息管理列表
     */
    @GetMapping("/list")
    public TableDataInfo schoolGradeInfoList(SchoolDegreeInfo schoolGradeInfo) {
        startPage();
        List<SchoolDegreeInfo> list = schoolGradeInfoService.selectSchoolGradeInfoList(schoolGradeInfo);
        return getDataTable(list);
    }


    /**
     * 导出学籍信息管理列表
     */
    @PostMapping("/export")
    public void schoolGradeInfoExport(HttpServletResponse response, SchoolDegreeInfo schoolGradeInfo) {
        List<SchoolDegreeInfo> list = schoolGradeInfoService.selectSchoolGradeInfoList(schoolGradeInfo);
        ExcelUtil<SchoolDegreeInfo> util = new ExcelUtil<SchoolDegreeInfo>(SchoolDegreeInfo.class);
        util.exportExcel(response, list, "数据");
    }


    /**
     * 获取学籍信息管理详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult schoolGradeInfoGetInfo(@PathVariable("id") Long id) {
        return success(schoolGradeInfoService.selectSchoolGradeInfoById(id));
    }


    @PostMapping
    public AjaxResult schoolGradeInfoAdd(@RequestBody SchoolDegreeInfo schoolGradeInfo) {
        return toAjax(schoolGradeInfoService.insertSchoolGradeInfo(schoolGradeInfo));
    }


    /**
     * 修改学籍信息管理
     */
    @PutMapping
    public AjaxResult schoolGradeInfoEdit(@RequestBody SchoolDegreeInfo schoolGradeInfo) {
        return toAjax(schoolGradeInfoService.updateSchoolGradeInfo(schoolGradeInfo));
    }

    /**
     * 删除学籍信息管理
     */
    @DeleteMapping("/{ids}")
    public AjaxResult schoolGradeInfoRemove(@PathVariable Long[] ids) {
        return toAjax(schoolGradeInfoService.deleteSchoolGradeInfoByIds(ids));
    }
}
